﻿using System;
using Gma.QrCodeNet.Encoding;

namespace Qr
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Console.Write(@"Type some text to QR code: ");//the line for remind the customer to cin
			string sampleText = Console.ReadLine();//set the sampleTest to the cinLine
			QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.M);//new a class for using
			QrCode qrCode = qrEncoder.Encode(sampleText);//set up the qrCode for the cinLine
			if (qrCode.Matrix.Width != 4) {
				Console.WriteLine ("the string you cin is not containing four letters");
			} //remind the wrong situation
			for (int j = 0; j < qrCode.Matrix.Width; j++) {
				for (int i = 0; i < qrCode.Matrix.Width; i++) {
					char charToPrint = qrCode.Matrix [i, j] ? '█' : ' ';
					Console.Write (charToPrint);
				}//horizontal
				Console.WriteLine ();
			}//vertical
			Console.WriteLine (@"Press any key to quit.");//remind the customer to quit
			Console.ReadKey ();//cin the key of the QRcode.
		}
	}
}

